---
layout: blog-default
titles:
  en: All Posts
  zh: 归档
  zh-Hans: 归档
  zh-Hant: 歸檔
---
<div class="m-all">
    <div class="main">
        {% include snippets/page-title.html %}
        <h1 class="js-page-heading">{{ __return }}</h1>
        {% include blog/tags.html %}
        <!--group by year: http://stackoverflow.com/questions/19086284/jekyll-liquid-templating-how-to-group-blog-posts-by-year-->
        <section class="js-year-wrapper">
            {% for post in site.posts %}
                {% assign currentdate = post.date | date: '%Y' %}
                {% if currentdate != date %}
                    {% unless forloop.first %}</ul></section>{% endunless %}
                    <section id="{{ post.date | date: "%Y" }}">
                    <h2 class="year-title" id="year-{{ post.date | date: "%Y" }}">{{ currentdate }}</h2>
                    <ul class="year-list">
                    {% assign date = currentdate %}
                {% endif %}
                {% assign _tags = '' %}
                {% for tag in post.tags %}
                    {% assign _tag = tag | strip | url_encode %}
                    {% assign _tags = _tags | append: ',' | append: _tag %}
                {% endfor %}
                {% assign last = _tags | size | minus: 1 %}
                {% assign _tags = _tags | slice: 1, last %}
                {% assign __path = post.url %}
                {% include snippets/prepend-baseurl.html %}
                {% assign href = __return %}
                {% assign __locale = site.data.locale.ARTICLE_LIST_DATE_FORMAT %}
                {% include snippets/locale-to-string.html %}
                <li class="js-post-block" data-tag="{{ _tags }}">
                    <span class="post-date">{{ post.date | date: __return }}</span>
                    <a class="post-link" href="{{ href }}">{{ post.title }}</a></li>
                {% if forloop.last %}</ul></section>{% endif %}
            {% endfor %}
        </section>
    </div>
</div>
{% include snippets/page-title.html %}
<script type="text/javascript">
    // function queryString is copied from
    // http://stackoverflow.com/questions/979975/how-to-get-the-value-from-url-parameter#answer-979995
    function queryString() {
        // This function is anonymous, is executed immediately and
        // the return value is assigned to QueryString!
        var i = 0, queryObj = {}, pair;
        var queryStr = window.location.search.substring(1);
        var queryArr = queryStr.split('&');
        for (i = 0; i < queryArr.length; i++) {
            pair = queryArr[i].split('=');
            // If first entry with this name
            if (typeof queryObj[pair[0]] === 'undefined') {
                queryObj[pair[0]] = pair[1];
            // If second entry with this name
            } else if (typeof queryObj[pair[0]] === 'string') {
                queryObj[pair[0]] = [queryObj[pair[0]], pair[1]];
            // If third or later entry with this name
            } else {
                queryObj[pair[0]].push(pair[1]);
            }
        }
        return queryObj;
    }

    $(function() {
        var $pageHeading = $('.js-page-heading');
        var $articleTag = $('.js-article-tag');
        var $tagShowAll = $('.js-tag-show-all');
        var $postBlock = $('.js-post-block');
        var $yearSection = $('.js-year-wrapper section');

        window.tagSelect = function(tag) {
            var i = 0, flag = false, cur, tagStr = '',
                tags = [], _tag = '', lis = [];
            if (tag === undefined || tag === '') {
                $pageHeading.text('{{ __return }}');
                $tagShowAll.focus(); $postBlock.show();
            } else {
                tag = tag.trim();
                // $articleTag.filter('.tag-' + tag).focus();
                for (i = 0; i < $articleTag.length; i++) {
                    cur = $articleTag.eq(i); _tag = cur.data('tag');
                    if (typeof _tag === 'string' && _tag.trim() === tag) {
                        cur.focus(); tagStr = cur.children('span').text();
                        (typeof tagStr === 'string') && (tagStr = tagStr.trim());
                        $pageHeading.text('Tag: ' + tagStr); break;
                    }
                }
                $postBlock.each(function() {
                    flag = false, cur = $(this);
                    tags = cur.data('tag').split(',');
                    for (i = 0; i < tags.length; i++) {
                        _tag = tags[i].trim();
                        if (_tag === tag) {
                            flag = true; cur.show(); break;
                        }
                    }
                    flag || (cur.hide());
                });
            }
            $yearSection.each(function() {
                flag = false, cur = $(this);
                lis = cur.find('li');
                for (i = 0; i < lis.length; i++) {
                    if(lis.eq(i).css('display') !== 'none') {
                        flag = true; break;
                    }
                }
                flag ? cur.show() : cur.hide();
            });
            tag === undefined || window.history.replaceState(null, '', window.location.href.split('?')[0] + '?tag=' + tag);
        }

        var query = queryString();
        var tag = undefined;
        query.tag === undefined || (tag = query.tag);
        tagSelect(tag);
    });
</script>
